package top.aoyudi.entity;

import lombok.*;

import java.util.Objects;

@Data
@AllArgsConstructor
@NoArgsConstructor
public class UserFile {
    /**
     * 文件名
     */
    private String name;

    /**
     * 修改日期
     */
    private String date;

    /**
     * 类型
     */
    private String type;

    /**
     * 文件大小
     */
    private long size;

    public UserFile(String name, String date, String type) {
        this.name = name;
        this.date = date;
        this.type = type;
    }

    @Override
    public String toString() {
        if (Objects.equals(type, "文件夹")) {
            return String.format("%-20s\t\t\t%-15s\t\t%-5s", name, date, type);
        }
        return String.format("%-20s\t\t\t%-15s\t\t%-5s\t\t%-1dKB", name, date, type, size / 1024);
    }
}
